<%@ page language="java" import="java.util.*,com.lab.po.Student"
	pageEncoding="utf-8"%>
<%@ page import="com.lab.dao.impl.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>显示学院或专业信息</title>

     <style type="text/css">
       input[type="text"]{
              height: auto;
	          margin-top: 8px;
	          padding: 3px 9px;
            }
        a {
  			cursor:pointer;
		}
     </style>
     <script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery-1.8.3.js"></script>
     </head>
	
	


<script type="text/javascript">

	
function query(currentPage){
	
		var col_id=$("#college").val();
		$("#delup").html('');
		$("#delup").append("<a href='deleteServlet?method=deleteCollege&col_id="+parseInt(col_id)+"' class='btn btn-danger'>删除</a>&nbsp;"
				+"<a href='preServlet?method=updateCollege&col_id="+parseInt(col_id)+"' class='btn btn-primary'>更新</a>");

		$("#majtable").html('');
		$("#majtable").append("<tr><td align='center'><strong>专业编号</strong></td><td align='center'><strong>专业名称</strong></td><td align='center' ><strong>执行操作</strong></td></tr>")
		$.ajax({
			url:"${pageContext.request.contextPath}/majorAjax",
			type:"post",
			data:{col_id:col_id,currentPage:currentPage},
			dataType:"json",
			success:function(result){
				
				$.each(result,function(inx,ele){	
					$("#majtable").append("<tr><td align='center'>"+ele.maj_id+"</td><td align='center'>"+ele.maj_name+"</td>"
							+"<td align='center'>"
							+"<a onclick='det("+ele.maj_id+")' class='btn btn-danger'>删除</a>"
							+"<a href='preServlet?method=updateMajor&maj_id="+ele.maj_id+"' class='btn btn-primary'>更新</a></td></tr>");
					
				})
			}
		});
	$.ajax({
		url:"${pageContext.request.contextPath}/majPageAjax",
		type:"post",
		data:{col_id:col_id,currentPage:currentPage},
		dataType:"text",
		success:function(result){	
			$("#pagetable").html('');
				$("#pagetable").append(result);
		}
	});
}
function det(id){
	if(confirm("确定要删除吗？")) {
		location.href = "${pageContext.request.contextPath}/deleteServlet?method=deleteMajor&maj_id=" + id;
	}
}
function dete(){
	if(confirm("请选择想要删除的学院！")) {
	}
}
function upda(){
	if(confirm("请选择想要更新的学院！")) {
	}
}
</script>
	<body>

        <div class="container" >
        </div>
		<table  class="table table-hover table-condensed">
		    <tr>
				<td align="center"><strong>学院</strong></td>
				<td align="center" ><strong>执行操作</strong></td>
			</tr>
			<tr>
				<td>
				<select name="college" id="college" style="width: 180px" onchange="query(1)">
					<option value=0 >请选择需要维护的学院</option>
					<c:forEach items="${collegeList}" var="college" >
						<option value="${college.col_id }">${college.col_name }</option>
					</c:forEach>
				</select>
				</td>
				<td align="center" id="delup">
					<a onclick="dete()" class="btn btn-danger">删除</a>
					<a onclick="upda()" class="btn btn-primary">更新</a>
				</td>
			</tr>
			<table class="table table-hover table-condensed" id="majtable">
			</table>
			<table class="table table-hover table-condensed" id="pagetable">
			</table>
		</table>	
		<hr>
		<a href="main.jsp" class="btn btn-success">返回主菜单</a>
		<hr>


	</body>
</html>
